#include "sg_obj.h"
#include "../lcd_drivers/lcd.h"

inline void SgObj_setPosition(void * this, u16 x, u16 y)
{
    Lcd_Clear(((sg_obj_t *)this)->Pos.x, ((sg_obj_t *)this)->Pos.y, ((sg_obj_t *)this)->Pos.x + ((sg_obj_t *)this)->Width - 1, ((sg_obj_t *)this)->Pos.y + ((sg_obj_t *)this)->Height - 1);
    ((sg_obj_t *)this)->Pos.x = x;
    ((sg_obj_t *)this)->Pos.y = y;
}

inline void SgObj_setBgColor(void * this, lcd_color_t bg_color)
{
    ((sg_obj_t *)this)->BgColor = bg_color;
}

inline void SgObj_setSize(void * this, u16 width, u16 height)
{
    ((sg_obj_t *)this)->Height = height;
    ((sg_obj_t *)this)->Width = width;
}

void SgObj_setStatus(void * this, sg_st_t st)
{
    ((sg_obj_t *)this)->Status = st;
    if(((sg_obj_t *)this)->Status == SG_ST_HIDE)
    {
        SgObj_clear(this);
    }
}

inline sg_st_t SgObj_getStatus(void * this)
{
    return ((sg_obj_t *)this)->Status;
}

void SgObj_clear(void * this)
{
    Lcd_Clear(((sg_obj_t *)this)->Pos.x, ((sg_obj_t *)this)->Pos.y, ((sg_obj_t *)this)->Pos.x + ((sg_obj_t *)this)->Width - 1, ((sg_obj_t *)this)->Pos.y + ((sg_obj_t *)this)->Height - 1);
}


